package com.hainatong.shiphelper.module.handlejob.adapter;

import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import com.blankj.utilcode.util.ToastUtils;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.databinding.ItemBossTagViewBinding;
import com.hainatong.shiphelper.module.workermgr.entity.WorkerBean;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;

import java.util.List;

public class BossTagAdapter<T> extends TagAdapter<WorkerBean>
{

    private OnTagClearClickListener clearClickListener;

    public OnTagClearClickListener getClearClickListener() {
        return clearClickListener;
    }

    public void setClearClickListener(OnTagClearClickListener clearClickListener) {
        this.clearClickListener = clearClickListener;
    }

    public BossTagAdapter(List<WorkerBean> bossList)
    {
        super(bossList);
    }

    @Override
    public View getView(FlowLayout parent, int position, WorkerBean boss)
    {
        ItemBossTagViewBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_boss_tag_view, null,false);

        binding.tvBossName.setText( boss.getUserTrueName()  );

        binding.btnClearImg.setOnClickListener( v -> {
            if( clearClickListener != null )
            {
                clearClickListener.onClearClick(position,boss);
            }
        } );

        return binding.getRoot();
    }


    @Override
    public void onSelected(int position, View view)
    {
        super.onSelected(position, view);
    }


    public interface OnTagClearClickListener
    {
        void onClearClick(int position,WorkerBean boss);
    }
}
